<?php

error_reporting(E_ALL);

function encodeerSimple(){
	
	$array1 = array('sinterklAas', 'hansje', 'pinocchio', 'ZwaRTE PIET');
	foreach($array1 as $value){
	$reverse = strrev($value);	
	
		if(ctype_lower($reverse{2}) == true){
			$reverse{2} = strtoupper($reverse{2});
		}
		elseif(ctype_upper($reverse{2}) == true){
			$reverse{2} = strtolower($reverse{2});
		}
		
	$EvenOneven = strlen($reverse)%2 == 0 ? "even" : "oneven";
	
		if($EvenOneven == "even"){
			$midden = strlen($reverse) / 2;
			$links = substr($reverse, 0, $midden);
			$rechts = substr($reverse, $midden);
			
			echo $rechts.'#'.$links;
			echo '<br />';
		}
		else{
			echo $reverse.",";
			echo '<br />';
		}
	}
}
print encodeerSimple();

function decodeerSimple(){
	
	$array1 = array('saAlkretnis', 'ejSnah','oiHcconip','TEiP ETRawZ');
	foreach($array1 as $value){	
	$dereverse = strrev($value);
	
	if(ctype_lower($dereverse{2}) == true){
		$reverse{2} = strtoupper($dereverse{2});
	}
	elseif(ctype_upper($dereverse{2}) == true){
		$reverse{2} = strtolower($dereverse{2});
	}
		
	$EvenOneven = strlen($dereverse)%2 == 0 ? "even" : "oneven";
	
		if($EvenOneven == "even"){
			$midden = strlen($dereverse) / 2;
			$links = substr($dereverse, 0, $midden);
			$rechts = substr($dereverse, $midden);
			
			echo $links.'#'.$rechts;
			echo '<br />';
		}
		else{
			echo $dereverse.",";
			echo '<br />';
		}
	}
}
print decodeerSimple();
?>